package com.baseproject.volley;

import com.alibaba.fastjson.JSON;

import java.io.UnsupportedEncodingException;

/**
 * Created by hp on 2017/3/28.
 */

public class HttpTask implements Runnable{

    private IHttpService httpService;


    public <T> HttpTask(T requestInfo, String url, IHttpListener httpListener) {
        this.httpService = new JSONHttpService();
        this.httpService.setUrl(url);
        this.httpService.setHttpCallBack(httpListener);
        if (null != requestInfo) {
            //将请求对象 解析成json
            String requestContent = JSON.toJSONString(requestInfo);
            try {
                this.httpService.setRequestData(requestContent.getBytes("UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    }

    public void execute() {

    }

    @Override
    public void run() {
        httpService.execute();
    }
}
